﻿using BCCommon;
using BCDto.Common.ErrorMessage;
using BCDto.TMS.SpecificServiceType;
using BCDto.TMS.TransferStation;
using BCDto.TMS.TransportSpecificServiceConfig;
using BCDto.TMS.TransportSpecificServiceConfigOverWrite;
using BCEntity.TMS.SpecificServiceType;
using BCEntity.TMS.TransportSpecificServiceConfig;
using BCEntity.TMS.TransportSpecificServiceConfigOverWrite;
using BCService.TMS.SpecificServiceType;
using BCService.TMS.TransferStation;
using BCService.TMS.TransportSpecificServiceConfig;
using BCTMSRESTful.Configs;
using BCTMSRESTful.Controllers.Management;
using Microsoft.AspNetCore.Mvc;


namespace BCTMSRESTful.Controllers.Management.TMS.TransportSpecificServiceConfig
{
    /// <summary>
    /// 运输特殊服务费配置接口
    /// </summary> 
    [ApiExplorerSettings(GroupName = "TMSAdmin")]
    [Route("api/v1/sim/[controller]")]
    public class TransportSpecificServiceConfigController : ManagementBaseController
    {
        #region var
        private ITransportSpecificServiceConfigService transportSpecificServiceConfigService;
        #endregion


        #region 构造函数
        /// <summary>
        /// 构造函数
        /// </summary> 
        public TransportSpecificServiceConfigController(ITransportSpecificServiceConfigService transportSpecificServiceConfigService)
        {
            this.transportSpecificServiceConfigService = transportSpecificServiceConfigService;
        }
        #endregion

        #region POST 添加  
        /// <summary>
        /// 添加新运输特殊服务费配置纪录
        /// </summary>
        /// <param name="dto">运输特殊服务费配置数据模型</param>
        /// <returns></returns>
        [Log("添加新运输特殊服务费配置纪录")]
        [HttpPost]
        [ProducesResponseType(typeof(TransportSpecificServiceConfigRequestDto), 200)]
        public IActionResult Post([FromBody] TransportSpecificServiceConfigRequestDto dto)
        {
            var a = transportSpecificServiceConfigService.Add(dto, this.Admin);
            return Ok(a);
        }

        #endregion

        #region PUT 修改   
        /// <summary>
        /// 修改运输特殊服务费配置纪录
        /// </summary>
        /// <param name="dto">运输特殊服务费配置数据模型</param>
        /// <returns></returns>
        [Log("修改运输特殊服务费配置纪录")]
        [HttpPut]
        [ProducesResponseType(typeof(TransportSpecificServiceConfigViewDto), 200)]
        public IActionResult Put([FromBody] TransportSpecificServiceConfigPutDto dto)
        {
            var a = Ok(transportSpecificServiceConfigService.Update(dto, this.Admin));
            return a;
        }
        #endregion

         


        #region 删除  
        /// <summary>
        /// 删除运输特殊服务费配置纪录
        /// </summary>
        /// <param name="transportSpecificServiceConfigId">运输特殊服务费配置ID</param>
        /// <returns></returns>
        [Log("删除运输特殊服务费配置纪录")]
        [HttpDelete("{transport_specific_service_config_id}")]
        [ProducesResponseType(typeof(NoContentResult), 204)]
        public IActionResult Delete([FromRoute(Name = "transport_specific_service_config_id")] long transportSpecificServiceConfigId)
        {
            transportSpecificServiceConfigService.Delete(transportSpecificServiceConfigId,Admin);
            return NoContent();
        }
        #endregion

        #region GetByID     
        /// <summary>
        /// 获取一条运输特殊服务费配置纪录
        /// </summary>
        /// <param name="transportSpecificServiceConfigId">运输特殊服务费配置ID</param>
        /// <returns></returns>
        [HttpGet("{transport_specific_service_config_id}")]
        [ProducesResponseType(typeof(TransportSpecificServiceConfigDto), 200)]
        public IActionResult Get([FromRoute(Name = "transport_specific_service_config_id")] long transportSpecificServiceConfigId)
        {
            return (Ok(transportSpecificServiceConfigService.GetById(transportSpecificServiceConfigId)));

        }
        #endregion

        #region Query 
        /// <summary>
        /// 查询运输特殊服务费配置 分页
        /// </summary>
        /// <param name="vehicleTypeId">车辆类型Id</param>
        /// <param name="specificServiceType">特殊服务类型</param>
        /// <param name="serviceTitle">服务标题</param> 
        /// <param name="pageIndex">页码</param>
        /// <param name="pageSize">页大小</param>
        /// <returns></returns>
        [HttpGet("[action]")]
        [ProducesResponseType(typeof(PageableList<TransportSpecificServiceConfigViewDto>), 200)]
        public IActionResult Query(
            [FromQuery(Name = "vehicle_type_id")] int? vehicleTypeId,
            [FromQuery(Name = "specific_service_type")] string specificServiceType,
            [FromQuery(Name = "service_title")] string serviceTitle,
            [FromQuery(Name = "index")] int? pageIndex = 1,
            [FromQuery(Name = "size")] int? pageSize = 10)
        {
            var a = Ok(transportSpecificServiceConfigService.GetList(Admin, vehicleTypeId, specificServiceType, serviceTitle, pageIndex.Value, pageSize.Value));
            return a;
        }
        #endregion


        #region GetOnlyList 
        /// <summary>
        /// 查询运输特殊服务费配置
        /// </summary>
        /// <param name="vehicleTypeId">车辆类型Id</param>
        /// <param name="specificServiceType">特殊服务类型</param>
        /// <param name="serviceTitle">服务标题</param>  
        /// <returns></returns>
        [HttpGet("[action]")]
        [ProducesResponseType(typeof(PageableList<TransportSpecificServiceConfigViewDto>), 200)]
        public IActionResult GetOnlyList(
            [FromQuery(Name = "vehicle_type_id")] int? vehicleTypeId,
            [FromQuery(Name = "specific_service_type")] string specificServiceType,
            [FromQuery(Name = "service_title")] string serviceTitle )
        {
            var a = Ok(transportSpecificServiceConfigService.GetOnlyList(vehicleTypeId, specificServiceType, serviceTitle));
            return a;
        }
        #endregion


    }
}